﻿using KouDai.Core.Engine;
using KouDai.Core.Models;
using KouDai.Core.Service;
using KouDai.Core.Service.Navigation;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Threading.Tasks;

namespace KouDai.Core.ViewModel
{
    public class ItemDetailViewModel : NavigateViewModel
    {
        #region Fields
        private readonly INavigateService _navigateService;
        private ObservableCollection<HoneyEntity> _itemDetails = new ObservableCollection<HoneyEntity>();
        #endregion

        #region Constructor
        public ItemDetailViewModel(INavigateService navigateService) :base(navigateService)
        {
            _navigateService = navigateService;

            //_itemDetails.Add(new HoneyEntity
            //{
            //    ID = "taobao16428206747",
            //    ImageUrlForIphone = "http://img.geilicdn.com/taobao16428206747_146x219.jpg",
            //    ImgRatio = "1.50",
            //    Name = "『Some Time』淑女范~领部褶皱荷叶边边棉服~预定",
            //    Price = "￥118"
            //});
            //_itemDetails.Add(new HoneyEntity
            //{
            //    ID = "taobao16428206747",
            //    ImageUrlForIphone = "http://img.geilicdn.com/taobao16428206747_146x219.jpg",
            //    ImgRatio = "1.50",
            //    Name = "『Some Time』淑女范~领部褶皱荷叶边边棉服~预定",
            //    Price = "￥118"
            //});
            //_itemDetails.Add(new HoneyEntity
            //{
            //    ID = "taobao16428206747",
            //    ImageUrlForIphone = "http://img.geilicdn.com/taobao16428206747_146x219.jpg",
            //    ImgRatio = "1.50",
            //    Name = "『Some Time』淑女范~领部褶皱荷叶边边棉服~预定",
            //    Price = "￥118"
            //});
            //_itemDetails.Add(new HoneyEntity
            //{
            //    ID = "taobao16428206747",
            //    ImageUrlForIphone = "http://img.geilicdn.com/taobao16428206747_146x219.jpg",
            //    ImgRatio = "1.50",
            //    Name = "『Some Time』淑女范~领部褶皱荷叶边边棉服~预定",
            //    Price = "￥118"
            //});
            //_itemDetails.Add(new HoneyEntity
            //{
            //    ID = "taobao16428206747",
            //    ImageUrlForIphone = "http://img.geilicdn.com/taobao16428206747_146x219.jpg",
            //    ImgRatio = "1.50",
            //    Name = "『Some Time』淑女范~领部褶皱荷叶边边棉服~预定",
            //    Price = "￥118"
            //});

            //_itemDetails.Add(new HoneyEntity
            //{
            //    ID = "taobao16428206747",
            //    ImageUrlForIphone = "http://img.geilicdn.com/taobao16428206747_146x219.jpg",
            //    ImgRatio = "1.50",
            //    Name = "『Some Time』淑女范~领部褶皱荷叶边边棉服~预定",
            //    Price = "￥118"
            //});
            //_itemDetails.Add(new HoneyEntity
            //{
            //    ID = "taobao16428206747",
            //    ImageUrlForIphone = "http://img.geilicdn.com/taobao16428206747_146x219.jpg",
            //    ImgRatio = "1.50",
            //    Name = "『Some Time』淑女范~领部褶皱荷叶边边棉服~预定",
            //    Price = "￥118"
            //});
            //_itemDetails.Add(new HoneyEntity
            //{
            //    ID = "taobao16428206747",
            //    ImageUrlForIphone = "http://img.geilicdn.com/taobao16428206747_146x219.jpg",
            //    ImgRatio = "1.50",
            //    Name = "『Some Time』淑女范~领部褶皱荷叶边边棉服~预定",
            //    Price = "￥118"
            //});
        } 
        #endregion

        #region Properties
        public ObservableCollection<HoneyEntity> ItemDetails
        {
            get { return _itemDetails; }
            set
            {
                if (value != _itemDetails)
                {
                    _itemDetails = value;
                    this.RaisePropertyChanged(() => this.ItemDetails);
                }
            }
        }
        #endregion

        #region Method
        protected override void OnDataSet()
        {
            string parameter = (string)base.Data;
            Debug.WriteLine("参数" + parameter);
        }

        public async Task GetItems()
        {
            BackData backData = await KouDaiService.GetHotImageWall("Combine_Default", 0);
            List<HoneyEntity> honeyItems = (List<HoneyEntity>)backData.ResposeData;
            Debug.WriteLine(honeyItems.Count);
            honeyItems.ToObservableCollection(this.ItemDetails);
        }
        #endregion

    }
}
